package com.itheima.work;

import java.io.*;

/**
 * @auther Macrydy
 * @date 2020/7/7 22:39
 */
public class FileUtils {
    public static Long copyFile(String str1,String str2) throws IOException {

        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(str1));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(str2));

        long start = System.currentTimeMillis();
        int len;
        while ((len=bis.read())!=-1){
            bos.write(len);
            bos.flush();
        }

        bos.close();
        bis.close();

        long end = System.currentTimeMillis();

        return end-start;
    }
}
